<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>统计数组元素出现次数</title>
</head>
<body>
    <script>

        /* var arr = [1, 2, 3, 1, 1, 1, 2, 2, 3, 3, 4];
        function getRepeatNum() {
            return arr.reduce(function (pre, cur) {
                pre[cur] = (pre[cur] + 1) || 1;
                return pre;
            }, {});
        } 
        console.log(getRepeatNum()); */

    </script>
</body>
</html>